package yunquan.wang.base.process;

import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.workitem.wsht.HornetQHTWorkItemHandler;
import org.jbpm.task.TaskService;
import org.jbpm.task.service.SyncTaskServiceWrapper;
import org.jbpm.task.service.hornetq.AsyncHornetQTaskClient;
import org.springframework.beans.factory.InitializingBean;

public class ProcessServiceHornetQ implements ProcessService,InitializingBean {
 
	private StatefulKnowledgeSession ksession;
	   TaskService taskClient;
	@Override
	public TaskService getTaskService() {
        
		return taskClient;
	}
	public void setKsession(StatefulKnowledgeSession ksession) {
		this.ksession=ksession;

 
	}
	@Override
	public void afterPropertiesSet() throws Exception {
		 taskClient = new SyncTaskServiceWrapper(new AsyncHornetQTaskClient("HumanTaskExample-testClient"));
	    HornetQHTWorkItemHandler hornetQHTWorkItemHandler = new HornetQHTWorkItemHandler(ksession);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", hornetQHTWorkItemHandler);
	}

}
